package com.util;
import java.util.Iterator;
import java.util.Set;

import redis.clients.jedis.Jedis;

public class Redis {

	public static String getRedisData(String key){
		Jedis jedis=RedisUtils.getJedis();
		String data = jedis.get(key);
		RedisUtils.returnResource(jedis);
		return data;
	}
	public static void setRedisData(String key,String value){
		Jedis jedis=RedisUtils.getJedis();
		jedis.set(key, value);
		RedisUtils.returnResource(jedis);
	}
	public static void delRedisData(String key){
		Jedis jedis=RedisUtils.getJedis();
		jedis.del(key);
		RedisUtils.returnResource(jedis);
	}
	public static void main(String[] args) {
      //redis.getRedisData("oo");
      //Redis.setRedisData("4607184725cb154d29dff55ab72c6165", "587737bbfeaf9a52c2091227");
      //System.out.println(Redis.getRedisData("faa2be2c318ff5b7cf94ab1ac1ca8786"));
      //redis.delRedisData("oo");
     
      //redis.delRedisData("tt");
      Redis.batchDel();
	}
	 public static  void batchDel(){
		 Jedis jedis=RedisUtils.getJedis();
	        Set<String> set = jedis.keys("*/weiboContextController/selectFirstWeibo.action" +"*");
	        System.err.println(set.size());;
	        Iterator<String> it = set.iterator();  
	        while(it.hasNext()){  
	            String keyStr = it.next();  
	            System.out.println(keyStr);  
	            jedis.del(keyStr);  
	        }
	        RedisUtils.returnResource(jedis);
	    }
	
}
